package com.example.kajinka.readbook;

import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;

/**
 * Created by kajinka on 2018/2/27.
 */

public class SecondActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        Intent intent = getIntent();//获取上一个activity传递过来的intent
        Toast.makeText(SecondActivity.this,intent.getStringExtra("2getDate"),Toast.LENGTH_LONG);
        System.out.print(intent.getStringExtra("2getDate"));
    }

    //按下返回键后执行的方法
    @Override
    public void onBackPressed() {
        Intent intent =new Intent();
        intent.putExtra("returnDate","返回数据");
        setResult(RESULT_OK,intent);
        finish();//销毁当前活动
    }
}